﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
using System.IO.Ports;
using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
using MasterDatabase;

namespace Job_Assignment
{
    public partial class Form1 : SQL_APPL
    {
        MaterDatabase ProductionPlanDetail_MasterDatabase;
        Button_Lbl ProductionPlanDetail_Create_BT;

        public string ProductionPlanDetail_Select_CMD = @"SELECT * FROM [JOB_ASSIGNMENT_DB].[dbo].[P_004_KeHoachSanXuatTheoTram] ";
        public string ProductionPlanDetail_Init_Database_CMD = @"SELECT * FROM [JOB_ASSIGNMENT_DB].[dbo].[P_004_KeHoachSanXuatTheoTram] 
                                                      WHERE [LineID] = ''";
        private bool ProductionPlanDetail_Exist = false;
		private int ProductionPlanDetail_Index = 7;

        private bool ProductionPlanDetail_Init()
        {
            if (ProductionPlanDetail_Exist == true)
            {
                if (tabControl1.TabPages.Contains(ProductionPlanDetail_MasterDatabase.MasterDatabase_Tab) == false)
                {
                    tabControl1.TabPages.Insert(tabControl1.TabPages.Count, ProductionPlanDetail_MasterDatabase.MasterDatabase_Tab);
                }
                tabControl1.SelectTab("ProductionPlanDetail");
                return true;
            }
            ProductionPlanDetail_Exist = true;

            // Init_ProductionPlanDetail_Excel();
            ProductionPlanDetail_MasterDatabase = new MaterDatabase(OpenXL, tabControl1, "ProductionPlanDetail", ProductionPlanDetail_Index, MasterDatabase_Connection_Str, 
                                                            ProductionPlanDetail_Init_Database_CMD, ProductionPlanDetail_Select_CMD,
                                                            3, null, filterStatusLabel, showAllLabel,
                                                            StatusLabel1, StatusLabel2, ProgressBar1);

            // Empl_Skill_List_MasterDatabase.MasterDatabase_GridviewTBL.dataGridView_View.Columns["Line_ID"].Frozen = true;
            ProductionPlanDetail_MasterDatabase.MasterDatabase_GridviewTBL.GridView.BackgroundColor = Color.White;
            ProductionPlanDetail_MasterDatabase.MasterDatabase_GridviewTBL.Import_BT.Visible = false;
            ProductionPlanDetail_MasterDatabase.MasterDatabase_GridviewTBL.Review_BT.Visible = false;
            ProductionPlanDetail_MasterDatabase.MasterDatabase_GridviewTBL.Delete_Rows_BT.Visible = false;

            //Dho-Fixme: Do we need to use the button "Check_BT"?
            PosSize possize = new PosSize();
            possize.pos_x = 200;
            possize.pos_y = 90;
            ProductionPlanDetail_Create_BT = new Button_Lbl(1, ProductionPlanDetail_MasterDatabase.MasterDatabase_Tab, "Create", possize, (AnchorStyles)AnchorStyles.Left | AnchorStyles.Top);
            ProductionPlanDetail_Create_BT.My_Button.Click += new EventHandler(ProductionPlanDetail_Create_BT_Click);
            ProductionPlanDetail_Create_BT.My_Button.Visible = true;

            return true;
        }
        // ExcelImportStruct[] ProductionPlanDetail_Excel_Struct;
        const int ProductionPlanDetail_INDEX = 0;

        // private void Init_ProductionPlanDetail_Excel()
        // {
            // if (ProductionPlanDetail_Excel_Struct == null)
            // {
                // ProductionPlanDetail_Excel_Struct = new ExcelImportStruct[3];
                // ProductionPlanDetail_Excel_Struct[0] = new ExcelImportStruct(0, "LineID", "LineID", Excel_Col_Type.COL_STRING, 20, true);
                // ProductionPlanDetail_Excel_Struct[1] = new ExcelImportStruct(1, "LineName", "LineName", Excel_Col_Type.COL_STRING, 50, false);
                // ProductionPlanDetail_Excel_Struct[2] = new ExcelImportStruct(2, "Mode", "Mode", Excel_Col_Type.COL_STRING, 20, false);
            // }
        // }

    }
}